#!/dis/sh -n
load std

for d in /opt/*/man/* /opt/*/*/man/* {
	or {ftest -d $d} {raise continue}
	n := `{basename $d}
	if {ftest -r $d/INDEX} {
		f := '/chan/man-' ^ $n ^ '-INDEX'
		or {ftest -w $f} {ramfile $f; cp /man/$n/INDEX $f}
		echo -n "{cat $f $d/INDEX} > $f
	}
	bind -b $d /man/$n
}

for d in /man/[1-9]* {
	n := `{basename $d}
	f := '/chan/man-' ^ $n ^ '-INDEX'
	or {ftest -r $f} {raise continue}
	or {diff $f $d/INDEX >/dev/null} {bind $f $d/INDEX}
}
